package com.jf.cloud.api.combo.feign;

import com.jf.cloud.common.feign.FeignInsideAuthConfig;
import com.jf.cloud.common.product.vo.ComboVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author zz
 * @date 2022/8/16 14:45
 */
@FeignClient(value = "jfcloud-combo",contextId ="combo")
public interface ComboFeignClient {

    /**
     * 根据套餐id获取套餐信息
     * @param comboId
     * @param sysType
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/combo/getComboWithProdInfoById")
    ServerResponseEntity<ComboVO> getComboWithProdInfoById(@RequestParam("comboId") Long comboId,@RequestParam("sysType") Integer sysType);

    /**
     *   根据spuId获取相关的套餐信息
     * @param shopId
     * @param spuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/combo/listComboInfoBySpuId")
    ServerResponseEntity<List<ComboVO>> listComboInfoBySpuId(@RequestParam("shopId") Long shopId,@RequestParam("spuId") Long spuId);

    /**
     * 根据商品id获取套餐信息
     * @param spuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/combo/comboVoListBySpuId")
    ServerResponseEntity<List<ComboVO>> comboVoListBySpuId(@RequestParam("spuId") Long spuId);

    /**
     * 商品下架时如果商品在套餐活动中且为主商品则失效套餐活动
     * @param spuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/combo/offComboMainSpu")
    ServerResponseEntity<Void> offComboMainSpu(@RequestParam("spuId") Long spuId);

    /**
     * 检查商品是否为套餐活动（状态正在进行中的）的主商品
     * @param spuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/combo/checkComboSpu")
    ServerResponseEntity<Boolean> checkComboSpu(@RequestParam("spuId") Long spuId,@RequestParam("shopId") Long shopId);

    /**
     * 根据套餐id集合检查套餐是否全部可用
     * @param comboIdList
     * @return 返回不可用套餐数量 0代表全部可用，其它数据代表有不可用的套餐
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/combo/checkComboIsUsable")
    ServerResponseEntity<Integer> checkComboIsUsable(@RequestBody List<Long> comboIdList);

    /**
     * 根据套餐商品上下级时删除套餐缓存
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/combo/removeComboSpuCache")
    ServerResponseEntity<Void> removeComboSpuCache(@RequestParam("spuId") Long spuId);

    /**
     * 据套餐id集合检查套餐是否全部可用
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/combo/getComboByComboIdList")
    ServerResponseEntity<List<ComboVO>> getComboByComboIdList(@RequestBody List<Long> comboIdList);
}
